﻿Namespace nHibernate.Models
    Public Class ArticleModel
        Public Sub New()
        End Sub

        Public Overridable Property ArticleID() As String
        Public Overridable Property ArticleDescription() As String
        Public Overridable Property ArticleWeight As Decimal
        Public Overridable Property ArticleText() As String
        Public Overridable Property ArticlePrice1Amount As Decimal
        Public Overridable Property ArticlePrice2Amount As Decimal
        Public Overridable Property ArticlePrice3Amount As Decimal
        Public Overridable Property ArticlePrice1Currency As Integer
        Public Overridable Property ArticlePrice2Currency As Integer
        Public Overridable Property ArticlePrice3Currency As Integer
        Public Overridable Property ArticlePrice1IsGross As Boolean
        Public Overridable Property ArticlePrice2IsGross As Boolean
        Public Overridable Property ArticlePrice3IsGross As Boolean
        Public Overridable Property ArticleCategory() As String

        Public Overridable Property TaxClass() As TaxClass
        Public Overridable Property ArticleUnit As Unit

        Public Overridable Function ToArticle() As Article
            Return New Article With {.ArticleCategory = ArticleCategory, .ArticleDescription = ArticleDescription, .ArticleID = ArticleID, .ArticlePrice1 = New EMoney(ArticlePrice1Amount, ArticlePrice1IsGross, ArticlePrice1Currency), _
                                             .ArticlePrice2 = New EMoney(ArticlePrice2Amount, ArticlePrice2IsGross, ArticlePrice2Currency), .ArticlePrice3 = New EMoney(ArticlePrice3Amount, ArticlePrice3IsGross, ArticlePrice3Currency), _
                                             .ArticleText = ArticleText, .ArticleUnit = ArticleUnit, .ArticleWeight = ArticleWeight, .TaxClass = TaxClass}
        End Function

        Public Shared Function FromArticle(a As Article) As ArticleModel
            Return New ArticleModel With {.ArticleID = a.ArticleID, .ArticleDescription = a.ArticleDescription, .ArticleCategory = a.ArticleCategory, .ArticlePrice1Amount = a.ArticlePrice1.Amount, .ArticlePrice1Currency = a.ArticlePrice1.Currency, .ArticlePrice1IsGross = a.ArticlePrice1.IsGross, _
                                          .ArticlePrice2Amount = a.ArticlePrice2.Amount, .ArticlePrice2Currency = a.ArticlePrice2.Currency, .ArticlePrice2IsGross = a.ArticlePrice2.IsGross, _
                                          .ArticlePrice3Amount = a.ArticlePrice3.Amount, .ArticlePrice3Currency = a.ArticlePrice3.Currency, .ArticlePrice3IsGross = a.ArticlePrice3.IsGross, _
                                          .ArticleText = a.ArticleText, .ArticleUnit = a.ArticleUnit, .ArticleWeight = a.WeightString, .TaxClass = a.TaxClass}
        End Function
    End Class
End Namespace

